package com.lyh.utils;

import com.lyh.pojo.PersonAndUser;

/**
 * 处理私密数据的工具类
 */
public class TackleDataUtils {

    /**
     * 加密手机号码
     */
    public static String phone(String previousPhone){
        return previousPhone.substring(0,3)+"****"+previousPhone.substring(7,previousPhone.length());
    }

    /**
     * 加密身份证号
     */
    public static String identify(String previousIdentify){
        return previousIdentify.substring(0,4) + "*********" + previousIdentify.substring(13,previousIdentify.length());
    }

    /**
     * 加密该用户对象的手机号和身份证号
     * @param previous 未加密的用户对象
     */
    public static void phoneAndIdentify(PersonAndUser previous){
        previous.setIdentify(identify(previous.getIdentify()));
        previous.setPhone(phone(previous.getPhone()));
    }

    /**
     * 翻译座位类型,从中文变成英文
     */
    public static String translateSeatType(String english){
        switch (english) {
            case "highGradeSleeper":
                english = "高级卧铺";
                break;
            case "firstClassSleeper":
                english = "一等卧";
                break;
            case "secondClassSleeper":
                english = "二等卧";
                break;
            case "softSleeper":
                english = "软卧";
                break;
            case "hardSleeper":
                english = "硬卧";
                break;
            case "businessSeat":
                english = "商务座";
                break;
            case "firstClassSeat":
                english = "一等座";
                break;
            case "secondClassSeat":
                english = "二等座";
                break;
            case "softSeat":
                english = "软座";
                break;
            case "hardSeat":
                english = "硬座";
                break;
            case "noSeat":
                english = "无座";
                break;
        }
        return english;
    }

    /**
     * 将驼峰座位类型变为下划线座位类型
     * @return 下划线座位类型
     */
    public static String changeSeatType(String previous){
        switch (previous){
            case "highGradeSleeper": previous = "high_grade_sleeper"; break;
            case "firstClassSleeper": previous = "first_class_sleeper"; break;
            case "secondClassSleeper": previous = "second_class_sleeper"; break;
            case "softSleeper": previous = "soft_sleeper"; break;
            case "hardSleeper": previous = "hard_sleeper"; break;

            case "businessSeat": previous = "business_seat"; break;
            case "firstClassSeat": previous = "first_class_seat"; break;
            case "secondClassSeat": previous = "second_class_seat"; break;
            case "softSeat": previous = "soft_seat"; break;
            case "hardSeat": previous = "hard_seat"; break;
            case "noSeat": previous = "no_seat"; break;
        }
        return previous;
    }


}
